<?php
import( 'tools.Setup.classes.BaseSetupScreen' );
class DatabaseSetupScreen extends BaseSetupScreen
{
	protected $dbc;
	protected $prefix	= "";
	
	protected function connectDatabase( $dba )
	{
		$this->dbc	= @mysql_connect( $dba['hostname'], $dba['username'], $dba['password'] );
		if( !$this->dbc )
			throw new Exception( "Database is not accessible." );
		if( !@mysql_select_db( $dba['database'] ) )
			throw new Exception( "Database is not existing." );
		$this->prefix	= $dba['prefix'];
		return $this->dbc;
	}
	
	protected function queryDatabase( $query )
	{
		$query	= str_replace( "{#prefix#}", $this->prefix, $query );
		$result	= @mysql_query( $query, $this->dbc );
		if( mysql_error() )
			return false;
		return $result;
	}
}
?>